import { env } from '$src/config/env';

export * from './rate-limiter';

const {
  CLOUDFLARE_BUCKET_DOMAIN,
  CLOUDFLARE_ACCESS_KEY,
  CLOUDFLARE_SECRET_ACCESS_KEY,
  CLOUDFLARE_ACCOUNT_ID,
  CLOUDFLARE_RENDERING_API_KEY
} = env;

export const CLOUDFLARE = {
  CONFIGS: {
    BUCKET_DOMAIN: CLOUDFLARE_BUCKET_DOMAIN!,
    ACCESS_KEY: CLOUDFLARE_ACCESS_KEY!,
    RENDERING_API_KEY: CLOUDFLARE_RENDERING_API_KEY!,
    SECRET_ACCESS_KEY: CLOUDFLARE_SECRET_ACCESS_KEY!,
    ACCOUNT_ID: CLOUDFLARE_ACCOUNT_ID!
  },
  R2: {
    BUCKET: 'videos',
    BUCKET_DOMAIN: CLOUDFLARE_ACCOUNT_ID
      ? `https://${CLOUDFLARE_ACCOUNT_ID}.r2.cloudflarestorage.com`
      : CLOUDFLARE_BUCKET_DOMAIN!,
    PRESIGN_EXPIRATION_TIME: 60 * 60, // 1 hour
    DOWNLOAD_EXPIRATION_TIME: 60 * 60 // 1 hour
  }
} as const;
